package org.coderk.mybatis.controller;

import org.springframework.http.HttpRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * @author: TanJingyu
 * @create: 2021-04-06 11:17
 **/
@RestController
public class RemoteController implements RemoteControllerParent{

    @PutMapping("/{id}/name")
    public ResponseEntity test(@PathVariable String id, @RequestBody CategoryRequestPayload requestPayload) {

        return ResponseEntity.ok(requestPayload.getImg());
    }

    @GetMapping("/test")
    public String test() {
        return "test...";
    }

    @PostMapping("push-order")
    public Object pushOrder(HttpServletRequest request) {
        HashMap<Object, Object> result = new HashMap<>();
        result.put("msg", "成了");
        return result;
    }

    public static class CategoryRequestPayload {
        private String name;
        private String img;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getImg() {
            return img;
        }

        public void setImg(String img) {
            this.img = img;
        }
    }
}
